<?php

class model_category extends Model {
    public function __construct() {
        parent::__construct();
    }

    public function getCategories() {
        return $this->db->query("SELECT a.*, b.description FROM #_gallery_categories a LEFT JOIN #_gallery_categories_description b ON b.category_id = a.category_id WHERE a.active = '1' ORDER BY a.category_name")->rows;
    }

    public function getCategoryById($cid) {
        $return = array();
        $rows = $this->db->query("SELECT a.*, b.description FROM #_gallery_categories a LEFT JOIN #_gallery_categories_description b ON b.category_id = a.category_id WHERE a.category_id = '$cid'")->rows;
        if(count($rows)) {
            $return = $rows[0];
        }
        return $return;
    }
}
?>
